<template>
  <div style="width: 100%; height: 100%;overflow:hidden">

    <div class="login-1">
      <div class="login-2">
        <div class="login-3">
          欢迎登录 杭电Online!
        </div>
        <el-form
            :model="form"
            status-icon
            :rules="rules"
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
        >

          <el-form-item label="用户名" prop="username">
            <el-input
                placeholder="账号名"
                v-model="form.username"
            />
          </el-form-item>

          <el-form-item label="密码" prop="password">
            <el-input
                placeholder="密码"
                type="password"
                v-model="form.password"
                autocomplete="off"
            />
          </el-form-item>
          <el-form-item prop="agree" style="margin-left: 50px" label-width="22px">
            <el-checkbox size="large" v-model="Agreed">
              我已同意隐私条款和服务条款
            </el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" plain @click="login">登录</el-button>

            <el-button plain @click="register">注册</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>

  </div>


</template>

<script>
import axios from "axios";

export default {
  name: "login.vue",
  data() {
    return {
      form: {},
      // validCode:'',
      Agreed: '',
      rules: {
        username: [
          {required: true, message: '请输入用户名', trigger: 'blur'},
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
        ]
      }
    }

  },
  methods: {
    login() {
      const params = new URLSearchParams();
      params.append('username', this.form.username);
      params.append('password', this.form.password);

      axios.post('api/user/login', params).then(res => {
        // console.log(res.data)
        if (res.data.code === 10000) {
          this.$message({
            type: "success",
            message: "登录成功"
          })
          this.$router.push("/interview")
        } else {
          this.$message({
            type: "error",
            message: res.data.message
          })
        }
      })
    },
    register() {
      console.log("1")
    }
  }
}

</script>

<style scoped>
.login-header {
  background: #fff;
  border-bottom: 1px solid #e4e4e4;
}

.login-footer {
  display: flex;
  float: bottom;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  height: 60vh; /* 设置容器高度，这里使用视口高度作为示例 */

}

.login-1 {

  width: 400px;
  height: 350px;
  box-shadow: 2px 2px 10px #909090;
  padding: 30px;
  margin: 100px 500px 20px auto;

}

.login-2 {
  width: 350px
}

.login-3 {
  display: flex;
  justify-content: center;
  color: #0c1504;
  font-size: 20px;
  text-align: center;
  padding-bottom: 40px;
  padding-left: 40px
}

.body {
  background-image: url('../assets/img/login.png');
  background-size: cover;
  background-position: center ;
  background-repeat: no-repeat;
}
</style>